﻿using EFEntity;
using Iservices;
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Services
{
    public class Second_kindServices : Isecond_kindServices
    {
        private readonly MyDbContext myDbContext;

        public Second_kindServices(MyDbContext myDbContext)
        {
            this.myDbContext = myDbContext;
        }

        public Task<int> Add(config_file_second_kind fsd)
        {
            throw new NotImplementedException();
        }

        public Task<int> Delete(int id)
        {
            throw new NotImplementedException();
        }

        public async Task<List<config_file_second_kind>> GetFirstId(string ids)
        {
            List<Econfig_file_second_kind> elist = new List<Econfig_file_second_kind>();
            List<config_file_second_kind> list = new List<config_file_second_kind>();
            await Task.Run(() =>
            {
                elist = (from e in myDbContext.config_file_second_kind
                         where e.first_kind_id == ids
                         select e).ToList();
                foreach (Econfig_file_second_kind item in elist)
                {
                    config_file_second_kind config = new config_file_second_kind()
                    {
                        fsk_id = item.fsk_id,
                        first_kind_id = item.first_kind_id,
                        first_kind_name = item.first_kind_name,
                        second_kind_id = item.second_kind_id,
                        second_kind_name = item.second_kind_name,
                        second_salary_id = item.second_salary_id,
                        second_sale_id = item.second_sale_id
                    };
                    list.Add(config);
                }
            });
            return list;
        }

        public async Task<List<config_file_second_kind>> selectAll()
        {
            List<Econfig_file_second_kind> list = new List<Econfig_file_second_kind>();
            await Task.Run(() =>
            {
                list = myDbContext.config_file_second_kind.ToList();
            });
            List<config_file_second_kind> list2 = new List<config_file_second_kind>();
            foreach (Econfig_file_second_kind item in list)
            {
                config_file_second_kind fd = new config_file_second_kind()
                {
                    fsk_id = item.fsk_id,
                    first_kind_id = item.first_kind_id,
                    first_kind_name = item.first_kind_name,
                    second_kind_id = item.second_kind_id,
                    second_kind_name = item.second_kind_name,
                    second_salary_id = item.second_salary_id,
                    second_sale_id = item.second_sale_id
                };
                list2.Add(fd);
            }
            return list2;
        }

        public Task<int> update(config_file_second_kind fsd)
        {
            throw new NotImplementedException();
        }
    }
}
